/**
 * @author YUN
 */
package a.db;

import java.util.ArrayList;
import java.util.List;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;
import android.util.Log;

public abstract class SqliteObject implements BaseColumns {
	private String mName;
	private List<String> mColumnNames;

	SqliteObject(String name) {
		this.mName = name;
		this.mColumnNames = new ArrayList<String>();
	}

	protected String getName() {
		return mName;
	}

	protected void addColumn(String column) {
		mColumnNames.add(column);
	}

	protected List<String> getColumn() {
		return mColumnNames;
	}

	public final void create(SQLiteDatabase db) {
		Log.d(getClass().getSimpleName(), toCreateSql());
		db.execSQL(toCreateSql());
	}

	public final void drop(SQLiteDatabase db) {
		Log.d(getClass().getSimpleName(), toDropSql());
		db.execSQL(toDropSql());
	}

	@Override
	public final String toString() {
		return "----CREATE---\n" + toCreateSql();
	}

	abstract String toCreateSql();

	abstract String toDropSql();
}
